<template>
  <div>
    <!-- <div class="navBar">
      <img class="nav_back" src="@/assets/imgs/fanhui.png" alt />
      <div class="nav_title">油站详情</div>
    </div>-->
    <div class="details_box">
      <div class="deta_head">
        <div class="head_msg_box">
          <div class="site_item">
            <div class="item_left">
              <div class="head_box">
                <van-image round width="50px" height="50px" :src="userObj.handlUrl" />
                <div>
                  <div style="margin-left:10px;" class="item_title">{{userObj.nickName}}</div>
                  <!-- <div class="item_title">{{userObj.sexDesc}}</div> -->
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
    <div>
      <van-tabs v-model="active" @change="handChangeOrder" swipeable>
        <van-tab v-for="ele in list" :key="ele.id" :title="ele.name">
          <div class="order_list" v-if="orderList.length!=0">
            <div
              class="order_item"
              v-for="(item,index) in orderList"
              :key="index"
              @click="handDetails"
            >
              <div class="item_title">
                <div class="title">{{item.litre}} {{item.oilNo}} {{item.gasName}}</div>
                <div class="time">{{item.orderTime}}</div>
              </div>
              <div class="item_img">
                <!-- <van-tag v-if="item.orderStatusName==1" type="success" size="medium">已支付</van-tag>
                <van-tag v-if="item.orderStatusName==4" type="primary" size="medium">退款申请中</van-tag>
                <van-tag v-if="item.orderStatusName==5" size="medium">已退款</van-tag>
                <van-tag v-if="item.orderStatusName==6" type="danger" size="medium">退款失败</van-tag>-->
                <img v-if="item.orderStatusName==1" class="img" src="@/assets/imgs/zhifu.png" alt />
                <img v-if="item.orderStatusName==4" class="img" src="@/assets/imgs/tuikuan.png" alt />
                <img
                  v-if="item.orderStatusName==5"
                  class="img"
                  src="@/assets/imgs/yituikuan.png"
                  alt
                />
                <img v-if="item.orderStatusName==6" class="img" src="@/assets/imgs/shibai.png" alt />
              </div>
              <div class="item_pic">￥{{item.amountGun}}</div>
            </div>
          </div>
          <van-empty description="暂无数据" v-if="orderList.length==0" />
        </van-tab>
        <!-- <van-tab title="已支付订单"></van-tab>
        <van-tab title="未支付订单"></van-tab>
        <van-tab title="已取消"></van-tab>-->
      </van-tabs>
    </div>
  </div>
</template>

<script>
import {orderInfo} from '@/api/user'
export default {
  components: {},
  data() {
    return {
      userObj: {},
      list: [
        {
          name: '全部订单',
          id: 0
        },
        {
          name: '已支付',
          id: 1
        },
        {
          name: '退款申请中',
          id: 4
        },
        {
          name: '已退款',
          id: 5
        },
        {
          name: '退款失败',
          id: 6
        }
      ],
      active: '',
      orderList: []
    }
  },
  mounted() {
    if (JSON.parse(localStorage.getItem('user'))) {
      this.userObj = JSON.parse(localStorage.getItem('user'))
      console.log(this.userObj, '获取用户信息')
      orderInfo('').then(res => {
        console.log(res.data, '========')
        this.orderList = res.data
      })
    }
  },
  methods: {
    handDetails() {
      this.$router.push({
        name: 'oilDetails'
      })
    },
    handChangeOrder(val) {
      let ids = ''
      switch (val) {
        case 1:
          ids = 1
          break
        case 2:
          ids = 4
          break
        case 3:
          ids = 5
          break
        case 4:
          ids = 6
          break

        default:
          ids = ''
          break
      }
      console.log(val, '========')
      orderInfo(ids).then(res => {
        this.orderList = res.data
      })
      // this.orderList2 = this.orderList
      if (val != 0) {
        this.orderList.forEach(item => {
          item.sta = val
        })
        console.log(this.orderList, val)
      }
    }
  }
}
</script>

<style lang="scss" scoped>
.order_list {
  padding: 20px;
  .order_item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
    margin-bottom: 10px;
    .item_pic {
      font-size: 14px;
      color: #333;
    }
    .item_title {
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
      width: 150px;
      .title {
        font-size: 14px;
        color: #333;
        margin-bottom: 6px;
      }
      .time {
        font-size: 12px;
        color: #909399;
      }
    }
    .item_img {
      width: 70px;
      height: 70px;
      text-align: center;
      .img {
        width: 70px;
        height: 70px;
      }
    }
  }
}
.details_box {
  .details_time {
    margin-left: 60px;
    color: #909399;
    margin-top: 10px;
    margin-bottom: 20px;
  }
  .details_mak {
    background-color: hsla(0, 87%, 69%, 0.1);
    border-color: hsla(0, 87%, 69%, 0.2);
    color: #f56c6c;
    padding: 3px;
    border-radius: 5px;
    box-sizing: border-box;
    font-size: 11px;
  }
  .deta_head {
    width: 100%;
    height: 160px;
    background-image: linear-gradient(to right, #ea5455, #feb692);
    padding: 0 20px;
    box-sizing: border-box;
    padding-top: 40px;
  }
  .head_msg_box {
    width: 100%;
    border-radius: 10px;
    background-color: #fff;
    box-shadow: 0 2px 20px 0 rgba(0, 0, 0, 0.1);
  }
}
.navBar {
  display: flex;
  align-items: center;
  padding: 20px 20px;
  .nav_back {
    width: 16px;
    height: 16px;
    margin-right: 20px;
  }
  .nav_title {
    font-size: 14px;
  }
}
.site_item {
  padding: 16px;
  display: flex;
  justify-content: space-between;
  padding-bottom: 10px;
  margin-bottom: 20px;
  .item_right {
    text-align: center;
    .item_right_icon {
      margin-bottom: 8px;
      width: 18px;
      height: 18px;
    }
    .item_right_title {
      font-size: 12px;
      color: #909399;
    }
  }
  .item_left {
    .head_box {
      display: flex;
      align-items: center;
    }
    .head_img {
      width: 50px;
      height: 50px;
      border-radius: 50%;
      background: pink;
      margin-right: 10px;
    }
    .item_title {
      font-size: 15px;
      font-weight: bold;
      margin-bottom: 6px;
    }
    .item_location {
      display: flex;
      align-items: center;

      .location_icon {
        width: 12px;
        height: 12px;
      }
      color: #909399;
      margin-bottom: 6px;
    }
    .pic_box {
      margin-left: 60px;
      width: 100%;
      display: flex;
      align-items: center;
      // margin-bottom: 8px;
      .guobiao {
        color: #909399;
        font-size: 8px;
        margin-left: 8px;
        text-decoration: line-through;
      }
      .pic_rmb {
        font-size: 10px;
        color: red;
      }
      .pic_num {
        font-size: 22px;
        // font-weight: bold;
        color: red;
        margin-right: 5px;
      }
    }
    .dow_authentication {
      background-color: #ffcc99;
      color: #ff9900;
      padding: 3px;
      font-size: 10px;
      border-radius: 3px;
    }
  }
}
</style>
